<?php
class HtmlHelpers{
	/**
	 * Create a Add button for detail page of an item.
	 * @param $manager
	 * @param $action
	 * @param $type
	 * @param $id
	 * @return unknown_type
	 */
	public function addButton($manager,$action,$type,$id,$title=""){
		global $images;
		if(!$manager) return "_button error, manager parameter is empty;";
		if(!$action) return "_button error, action parameter is empty;";
		if(!$type) return "_button error, type parameter is empty;";
		if(!$id) return "_button error, id parameter is empty;";
		$image = __('cart','addButton_image');
		$alt   = __('cart','addButton_alt');
		$label = __('cart','addButton_label');
		$button=Html::link("$manager","$action","$type",$id,$label,
						array(	'description'=>"$title",
								'styleclass'=>"smallbutton fright",
								'image'=>$images.$image));
		return $button;
	}
	
	/**
	 * Create a a delete button for item from cart.
	 * @param $manager
	 * @param $action
	 * @param $type
	 * @param $id
	 * @return unknown_type
	 */
	public function deleteButton($manager,$action,$type,$id,$title=""){
		global $images;
		if(!$manager) return "_button error, manager parameter is empty;";
		if(!$action) return "_button error, action parameter is empty;";
		if(!$type) return "_button error, type parameter is empty;";
		if(!$id) return "_button error, id parameter is empty;";
		$image = __('cart','delButton_image');
		$alt   = __('cart','delButton_alt');
		$button=Html::link("$manager","$action","$type",$id,"",
						array(	'description'=>"$title",
								'styleclass'=>"",
								'image'=>$images.$image));
		return $button;
	}
	
	/**
	 * Create an Ajax button creating a remote call to update a page part.
	 * @param $manager
	 * @param $action
	 * @param $type
	 * @param $title
	 * @param $ajaxTarget
	 * @param $ajaxOptions
	 * @return string of the well formated html button link.
	 */
	public function ajaxAddButton($manager,$action,$type,$id,$title="",$options=array()){
		global $images;
		if(!$manager) return "_button error, manager parameter is empty;";
		if(!$action) return "_button error, action parameter is empty;";
		if(!$type) return "_button error, type parameter is empty;";
		if(!$id) return "_button error, id parameter is empty;";
		$image = __('cart','addButton_image');
		$alt   = __('cart','addButton_alt');
		$label = __('cart','addButton_label');
		$linkoptions=array(
				'ajaxTarget'=>$options['ajaxTarget'],
				'ajaxOptions'=>(isset($options['ajaxOptions'])?$options['ajaxOptions']:""),
				'description'=>"$title",
				'styleclass'=>"smallbutton".(isset($options['styleclass'])?" ".$options['styleclass']:""),
				'image'=>$images.$image
			);
		$button=Html::link("$manager","$action","$type",$id,$label,
						$linkoptions);
		return $button;
	}
	public function ajaxDeleteButton($manager,$action,$type,$id,$title="",$options=array()){
		global $images;
		if(!$manager) return "_button error, manager parameter is empty;";
		if(!$action) return "_button error, action parameter is empty;";
		if(!$type) return "_button error, type parameter is empty;";
		if(!$id) return "_button error, id parameter is empty;";
		$image = __('cart','delButton_image');
		$alt   = __('cart','delButton_alt');
		$linkoptions=array(
				'ajaxTarget'=>$options['ajaxTarget'],
				'ajaxOptions'=>(isset($options['ajaxOptions'])?$options['ajaxOptions']:""),
				'description'=>"$title",
				'styleclass'=>(isset($options['styleclass'])?" ".$options['styleclass']:""),
				'image'=>$images.$image
			);
		$button=Html::link("$manager","$action","$type",$id,"",$linkoptions);
		return $button;
	}
}
?>